#pragma once

#include <QWidget>
#include <QCheckBox>
#include <QRadioButton>
#include <QButtonGroup>
#include <QGridLayout>
#include <QVBoxLayout>
#include <QLabel>
#include <qtimer>
#include "qcustomplot.h"
#include "type.h"


class TitanCsiCameraInfo : public QWidget
{
	Q_OBJECT

public:
	TitanCsiCameraInfo(QWidget *parent = Q_NULLPTR);
	~TitanCsiCameraInfo();

	void initUI();
	void setCustomPlotProperty(QCustomPlot* plot);

signals:
	void previewImage(const QString& image);

public slots:
	void onUpdateHz(qreal hz);
	void onUpdateTime();
	void onShowPreviewImage(const QImage& image);
	void onImagePreview(int);
	void onShowCameraRate(const std::vector<TopicHz>& topicsRate);
private:
	QCustomPlot *csi_plot_;

	QGroupBox *groupBox_;

	QButtonGroup *csi_group_;
	QRadioButton *csi_front_left_;
	QRadioButton *csi_front_mid_;
	QRadioButton *csi_front_right_;
	QRadioButton *csi_left_;
	QRadioButton *csi_right_;

	QLabel *csi_front_left_hz_label_;
	QLabel *csi_front_mid_hz_label_;
	QLabel *csi_front_right_hz_label_;
	QLabel *csi_left_hz_label_;
	QLabel *csi_right_hz_label_;

	QLabel *imageLabel_;

	QGridLayout *gridlayout_;

	QTimer *updateTime_;

	QString time_;

	QVector<qreal> csi_front_left_hz_;
	QVector<qreal> csi_front_mid_hz_;
	QVector<qreal> csi_front_right_hz_;
	QVector<qreal> csi_left_hz_;
	QVector<qreal> csi_right_hz_;

	std::map<std::string, std::vector<double> > image_rate_;
	std::map<std::string, QCPGraph*> image_graph_;
	QStringList lineNames_;
	QStringList topicsList_;

	int currentId_;
	double min_hz_;
	double max_hz_;
	double key_;
};
